﻿package com.dcliment.elements
{
	/**
	 * My Goal here is to have an Metrics Object that can contain all the information needed to track an event/object/or even page
	 * 
	 * ex: Video Play Pause Button
	 * token = VideoPlayPause, objectState = "on" or "off"
	 *  
	 * @author dcliment
	 * version 1.2
	 * 
	 * NOTE: added hash tag and question ability
	 * 
	 */	
	public class MetricsElement extends Object implements IMetricsElement
	{
		public static var PAGE:String = "page";
		public static var EVENT:String = "event";
		public static var OVERLAY:String = "overlay";
		public static var QUESTION:String = "question";
		
		private var _type:String;
		private var _token:String;
		// Events
		private var _objectState:String;
		// Question Asnwer
		private var _hashTag:Number; 
		private var _textAnswer:String = null;
		
		public function MetricsElement()
		{
		
		}
		/**
		 * use this to create a PAGE TOKEN ELEMENT
		 *  
		 * @param $token
		 * 
		 */		
		public function pageElement($token:String):void
		{
			_type = MetricsElement.PAGE;
			this.token = $token;
		}
		/**
		 * Use this to create a EVENT ELMENET
		 * 
		 * @param $token
		 * @param $objectState
		 * 
		 */		
		public function eventElement($token:String, $objectState):void
		{
			_type = MetricsElement.EVENT;
			this.token = $token;
			this.objectState = $objectState;
			
		}
		/**
		 * Use this to create OVERLAY Element
		 *  
		 * @param $token
		 * 
		 */		
		public function overlayElement($token:String):void
		{
			_type = MetricsElement.OVERLAY;
			this.token = $token;
		}
		/**
		 * Creates question answer element
		 * 
		 * NOTE:: REMEMBVER TO ADD THE HASH TAG
		 *  
		 * @param $token
		 * 
		 */		
		public function questionAnswerElement($token:String):void
		{
			_type = MetricsElement.QUESTION;
			this.token = $token;
		}
		
		/////////////////
		// Accessors
		////////////////
		public function set type(value:String):void
		{
			if(value == MetricsElement.PAGE || value == MetricsElement.EVENT || value == MetricsElement.OVERLAY || value == MetricsElement.QUESTION)
				_type = value;
			else
				throw new Error("MetricsElement.type(value:String) ERROR :: value = " + value + " :: Does not fit Metrics Element public static vars for approved types");
		}
		
		public function get type():String
		{
			return _type;
		}
		
		public function set token(value:String):void
		{
			_token = value;
		}
		
		public function get token():String
		{
			return _token;
		}
		
		public function set objectState(value:String):void
		{
			_objectState = value;
		}
		
		public function get objectState():String
		{
			return _objectState;
		}

		public function get hashTag():Number
		{
			return _hashTag;
		}

		public function set hashTag(value:Number):void
		{
			_hashTag = value;
		}

		public function get textAnswer():String
		{
			return _textAnswer;
		}

		public function set textAnswer(value:String):void
		{
			_textAnswer = value;
		}

	}
}